package com.zhsj.OkeHomeConsumption.ui.fragment.scancode;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.zhsj.OkeHomeConsumption.R;
import com.zhsj.OkeHomeConsumption.common.MyActivity;
import com.zhsj.OkeHomeConsumption.ui.activity.PayAmountActivity;
import com.zhsj.OkeHomeConsumption.ui.activity.wallet.ClearEditText;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * author : Xingdx
 * <p>
 * time   : 2018/10/18
 * desc   : 用户付款金额输入页面
 */
public final class InputPriceActivity extends MyActivity {

    @BindView(R.id.shop_img)
    ImageView shopImg;
    @BindView(R.id.text_name)
    TextView textName;
    @BindView(R.id.price_edit)
    ClearEditText priceEdit;
    @BindView(R.id.price_button)
    Button priceButton;

   private String shopName;

   private String code;

   private int shopid = -1;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_inputprice;
    }

    @Override
    protected int getTitleId() {
        return R.id.tb_inputprice_title;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {
        Bundle bundle = getIntent().getExtras();
        shopid= bundle.getInt("id");
        String shopLogo = bundle.getString("shopLogo");
        shopName = bundle.getString("shopName");
        code = bundle.getString("code");
        textName.setText(shopName);
        Glide.with(getActivity()).load(shopLogo).placeholder(R.drawable.zhanweitu_bg).into(shopImg);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick(R.id.price_button)
    public void onViewClicked() {
        String price = priceEdit.getText().toString().trim();
        if(price!=null&&!price.isEmpty()){
            startActivity(new Intent(this, PayAmountActivity.class)
                    .putExtra("pay_flage",1)
                    .putExtra("price",price)
            .putExtra("shopName",shopName)
            .putExtra("code",code)
            .putExtra("shopid",shopid));
            finish();
        }

    }
}